
/**
 * This is the abstract parent class to the 
 * checking and savings accounts. All common
 * code between the account classes is stored 
 * here, as well as the data fields.
 * @author Kristopher Gooding/Kyle Scharnhorst
 * @version 4/25/2014
 */
public abstract class Account {
	
    /**Account number for the account.*/
	protected int my_account_number;
	/**Name of the owner of the account.*/
	protected Member my_member;
	/**Balance of the money in the account.*/
	protected double my_balance;
	/**Next available account number.*/
	protected static int my_next_account_number = 0;
	/**Cost per period.*/
	protected static double my_cost = 1; // per period there is a cost
											// associated with this account

	// that equals 1 pound
    /**
     * constructor for the account class.
     * @param the_name
     * @param the_street
     * @param the_zipCode
     * @param the_town
     * @param country
     */
	public Account(final String the_name, final String the_street,
			final String the_zipCode, final String the_town, final String country) {
		my_member = new Member(the_name, the_street, the_town, the_zipCode, country);
	}
	
    /**
     * constructor for the account class.
     * @param the_name
     * @param the_street
     * @param the_zip_code
     * @param the_town
     * @param the_country
     * @param the_debit
     */
	public Account(final String the_name, final String the_street,
			final String the_zip_code, final String the_town,
			final String the_country, final float the_debit) {
		my_member = new Member(the_name, the_street, the_town, the_zip_code,
				the_country);
	}
	
    /**
     * constructor for the account class.
     * @param the_account_number
     */
	public Account(final int the_account_number) {
		my_account_number = the_account_number;
	}

	/**
	 * @return my_balance
	 */
	public double getBalance() {
		return my_balance;
	}
    
	/**
	 * @return my_account_number
	 */
	public int getAccountNumber() {
		return my_account_number;
	}
	
    /**
     * @return my_member
     */
	public Member getMember() {
		return my_member;
	}
	
    /**
     * prints the results of the toString.
     */
	public void print() {
		System.out.println(toString());
	}

	/**
	 * developes the string representation of the class using
	 * a string builder to combine all the specific information
	 * for the class.
	 */
	public String toString() {
		StringBuilder sb = new StringBuilder();

		sb.append("**************************************\n");
		sb.append("Savings account:     " + my_account_number + "\n");
		sb.append("Account holder name: " + my_member.getName() + "\n");
		sb.append("Address:             "
				+ my_member.getAddress().getStreet() + "\n");
		sb.append("                     "
				+ my_member.getAddress().getZipCode()); // /
		sb.append(" " + my_member.getAddress().getTown() + "\n");
		sb.append(my_member.getAddress().getCountry().toUpperCase() + "\n");
		sb.append("**************************************" + "\n");
		sb.append("Balance:  " + my_balance + "\n");
		sb.append("**************************************" + "\n");

		return sb.toString();
	}

}
